package al.softsynergy.auk.ui;


import al.softsynergy.auk.AukApplication;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;

public class LoginWindow extends Window {

	private TextField username = new TextField("Perdoruesi: ");
	private TextField password = new TextField("Fjalekalimi: ");
	
	public LoginWindow(String caption) {
		super(caption);
		this.init();
		
	}
	public LoginWindow() {
		super();

		this.init();
	}
	
	private void init(){
		((VerticalLayout)this.getContent()).setHeight("100%");
		((VerticalLayout)this.getContent()).setMargin(false);
		
		VerticalLayout wrapper = new VerticalLayout();
		
		wrapper.setHeight("100%");
		wrapper.addStyleName("wrapper");
		this.addComponent(wrapper);
		
		VerticalLayout vl = new VerticalLayout();
		wrapper.addComponent(vl);
		VerticalLayout header = new VerticalLayout();
		header.addStyleName("header");
		header.setWidth("100%");
		header.setHeight("150px");
		vl.addComponent(header);
		
		
		VerticalLayout loginLayout = new VerticalLayout();
		
		loginLayout.setWidth("215px");
		loginLayout.setSpacing(true);
		loginLayout.addStyleName("login");
		wrapper.addComponent(loginLayout);
		wrapper.setExpandRatio(loginLayout, 2);
		
		FormLayout formLayout = new FormLayout();
		formLayout.setMargin(false);
		formLayout.addComponent(this.username);
	    formLayout.addComponent(this.password);  
		loginLayout.addComponent(formLayout);
		Button ok = new Button("HYR", new Button.ClickListener() {
			
			@Override
			public void buttonClick(ClickEvent event) {
				((AukApplication)getWindow().getApplication()).loadMainWindow();
				
			}
		});
		ok.setWidth(80, UNITS_PIXELS);
		loginLayout.addComponent(ok);
		loginLayout.setComponentAlignment(ok, Alignment.TOP_RIGHT);
	}
}
